package com.watsons.csd_process.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.watsons.csd_process.po.Issue;
import com.watsons.csd_process.service.SentryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class SentryServiceImpl implements SentryService {


    @Override
    public Issue Sentry2Issue(JSONObject object) {
        Issue issue = new Issue();
        issue.setProjectName(object.getString("project"));
        issue.setException(object.getJSONObject("event").getJSONObject("exception").toJSONString());
        issue.setSentryUrl(object.getString("url"));
        issue.setLocation(object.getJSONObject("event").getString("location"));
        issue.setEventId(object.getJSONObject("event").getString("event_id"));
        return issue;
    }
}
